<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>购买房卡</title>
<meta name="keywords" content=""/>
<meta name="description" content=""/>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="format-detection" content="telephone=no"/>
<link rel="stylesheet" href="__STATIC__/css/common.css">
<link rel="stylesheet" href="__STATIC__/css/buycode.css">
<link rel="stylesheet" href="__STATIC__/css/swiper-4.2.2.min.css">
<script>
    window.onload = window.onresize =function(){
    	document.documentElement.style.fontSize = 100/750*document.documentElement.clientWidth + "px";
    }    
</script>
</head>
<body>
	<div class="warp">
		<div class="banner">
			<div class="swiper-container">
			    <div class="swiper-wrapper">
			        <div class="swiper-slide"><img src="__STATIC__/img/banner.jpg" alt=""></div>
			        <div class="swiper-slide"><img src="__STATIC__/img/banner2.jpg" alt=""></div>
			        <div class="swiper-slide"><img src="__STATIC__/img/banner3.jpg" alt=""></div>
			    </div>
			</div>
		</div>
		<div class="zhifu-form">
			<p class="zhifu-title">请输入您的游戏id账号</p>
			<input class="zhifu-zhanghao" type="num" pattern="[0-9]*" placeholder="账号">
			<p class="zhifu-title">请选择购买的张数</p>
			<input class="zhifu-num" type="num" pattern="[0-9]*" placeholder="数量">
			<p class="fangka-price">目前房卡每张￥<span></span></p>
			<div class="zhifu-all">
				<span>您需支付</span>
				<span>￥</span>
			</div>
			<div class="zhifu-btn">提交</div>
			<div class="zhifu-liji" style="display:none">立即支付</div>
		</div>
	</div>
	<ul class="foot">
		<li class="buy"><a href="{:url('index/buycode')}">购买房卡</a></li>
		<li><a href="{:url('index/code')}">我的邀请码</a></li>
		<li><a href="{:url('index/index')}">个人中心</a></li>
		<li><a href="{:url('index/friend')}">我的合伙人</a></li>
		<li><a href="{:url('index/get')}">奖励中心</a></li>
	</ul>

	<script src="__STATIC__/js/jquery-2.1.4.min.js"></script>
	<script src="__STATIC__/js/swiper-4.2.2.min.js"></script>
	<script>	 
		var mySwiper = new Swiper ('.swiper-container', {
		    loop: true,
		    autoplay:true
		  })  


		$.ajax({
		  url: '{:url("index/is_login")}',
		  type: 'post',
		  dataType: 'json',
		  // timeout: 1000,
		  success: function (data) {
		    if(data.code == 0){
		    	window.location.href = 'http://client.rup-china.com/yxzf/index.php/index/index/wechatLogin';
		    }
		  },
		  fail: function (err) {
		    console.log(err)
		  }
		})   

		//访问单价
		var price_fangka
		$.post("http://client.rup-china.com/yxzf/index.php/index/index/get_price",function(result){
			$('.fangka-price span').text(result.fk_price)
			//算总价
			$('.zhifu-num').on('input propertychange',function(){
				var price_all = ($(this).val()*result.fk_price).toFixed(2)
				$('.zhifu-all span:nth-child(2)').text(price_all)
			})
		})

		//验证账号信息
		var re = /^[0-9]+.?[0-9]*$/; 
		$('.zhifu-btn').click(function(){
			var game_id = $('.zhifu-zhanghao').val()
			if(!re.test(game_id)){
				alert('游戏帐号请输入数字')
				return false
			}
			$.post("http://client.rup-china.com/yxzf/index.php/index/index/gameid",{"gameid":game_id},function(result){
				var data = $.parseJSON( result ); 
				 console.log(data)
				 var user_id = data.Data
				$.post('http://client.rup-china.com/yxzf/index.php/index/index/setsession',{'gameid':game_id,'userid':user_id},function(result){
				})
				if(data.Success == false){
					alert(data.Msg);
				}
				if(data.Success == true){
					$('.zhifu-btn').hide()
					$('.zhifu-liji').show()
				}
			})
		})



		//立即支付
		$('.zhifu-liji').click(function(){
			var zhifu_num =  Number($('.zhifu-num').val())
			if(zhifu_num==""){
				return false
			}
			if(!re.test(zhifu_num)){
				alert('购买数量请输入数字')
				return false
			}
			window.location.href = 'http://client.rup-china.com/yxzf/index.php/index/pay/jsapi?type=fk'+zhifu_num
		})

	</script>

</body>
</html>